// ==UserScript==
// @name         百度搜索自动搜索下一页
// @namespace    https://gitee.com/LYF511511
// @version      0.1
// @description  百度搜索自动搜索下一页，推荐配合AC重定向！
// @author       LYF511
// @match        https://www.baidu.com/s?*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var httpRequest = new XMLHttpRequest();
    document.onscroll = function() {
         var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
        if(document.documentElement.scrollHeight == document.documentElement.clientHeight + scrollTop) {
            var container = document.getElementById("container");
            var n = container.getElementsByClassName("n")
            httpRequest.open('GET', n[n.length-1], true);
            httpRequest.send()
            httpRequest.onreadystatechange = function () {
                if (httpRequest.readyState == 4 && httpRequest.status == 200) {
                    var obj = document.createElement("div");
                    obj.innerHTML = httpRequest.responseText;
                    container.appendChild(obj.getElementsByClassName("result")[0].parentNode.parentNode);
                }
            }
        }
    }
})();